/******************************************************************************
 * @file led.h
 * 
 * @par dependencies
 * - stdio.h
 * - stdint.h
 * 
 * @author Shawn Li <2339679615@qq.com>
 * 
 * @brief Provide the HAL APIs of LED and corresponding options.
 * 
 * @version v0.1 2025-10-15
 * 
 * @date 2025-10-15
 * 
 * @copyright Copyright (c) 2025 Li Shan
 * All rights reserved.
 * 
 * @note 1 tap == 4 spaces!
 *       Code is UTF-8
 * 
******************************************************************************/

#ifndef __BSP_LED_H__
#define __BSP_LED_H__

//******************************** Includes *********************************//


#include <stdint.h>               //  the compiling lib.
#include <stdio.h>

#include "main.h"                 //  Core / OS layer
#include "cmsis_os.h"    

#include "queue.h"                //  specific file for operations
#include "stm32f4xx_hal.h"        
#include "stm32f4xx_hal_gpio.h"

//******************************** Includes *********************************//

//******************************** Defines **********************************//

/* function return status */
typedef enum
{
	LED_OK                = 0,         /* Operation completed successfully.  */
	LED_ERROR             = 1,         /* Run-time error without case matched*/
	LED_ERRORTIMEOUT      = 2,         /* Operation failed with timeout      */
	LED_ERRORRESOURCE     = 3,         /* Resource not available.            */
	LED_ERRORPARAMETER    = 4,         /* Parameter error.                   */
	LED_ERRORNOMEMORY     = 5,         /* Out of memory.                     */
	LED_ERRORISR          = 6,         /* Not allowed in ISR context         */
	LED_RESERVED          = 0x7FFFFFFF /* Reserved                           */
} led_status_t;

typedef enum
{
	LED_ON                = 0,         /* Turn on the LED.                   */
	LED_OFF               = 1,         /* Turn off the LED.                  */
	LED_TOGGLE            = 2,         /* Toggle the LED.                    */
	LED_BLINK             = 3,         /* Blink the LED.                     */
	LED_INITED_VALUE      = 0xFF       /* LED initialized value.             */
} led_operation_t;

//******************************** Defines **********************************//

//******************************** Declaring ********************************//

//******************** Thread_Function ******************//
extern osThreadId_t led_TaskHandle;
extern const osThreadAttr_t led_Task_attributes;
//******************** Thread_Function ******************//


//********************* Queue_Function ******************//
extern QueueHandle_t led_queue;

//********************* Queue_Function ******************//

/**
 * @brief Instantiates the led_operation_t target.
 * 
 * Steps:
 *  1. doing the specified operations.
 *  
 * @param[in] void        : Pointer to the target of handler.
 * 
 * @return led_status_t : Status of the function.
 * 
 * */
led_status_t led_on_off     (led_operation_t led_operation);

/**
 * @brief LED task entry function.
 *
 * This FreeRTOS task handles LED control operations. It typically waits for
 * requests (for example, from a queue or notifications) and then performs
 * LED actions such as turning on, turning off, or toggling an LED.
 *
 * The task implementation may block on @p EXTERNAL_QUEUE (defined above)
 * or use notifications depending on the design. The @p argument parameter is
 * the value supplied when creating the task and may be NULL.
 *
 * @param[in] argument Pointer passed to the task when created (may be NULL).
 */
void         led_task_func                  (void *argument);
//******************************** Declaring ********************************//


//**************************** Function Prototypes ***************************//



#endif // End of __BSP_LED_H__
